package com.example.entity;

import java.util.List;

import java.util.List;

/**
 * 分页结果封装
 * @param <T> 数据类型
 */
public class PageResult<T> {
    private int code;    // 状态码
    private String msg;  // 消息
    private List<T> rows; // 数据列表
    private long total;  // 总记录数

    // 成功静态方法
    public static <T> PageResult<T> success(List<T> rows, long total) {
        PageResult<T> result = new PageResult<>();
        result.setCode(200);
        result.setMsg("success");
        result.setRows(rows);
        result.setTotal(total);
        return result;
    }

    // getter和setter
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
}